<?php
/**
 * Jishupu-Laravel-Vue-Admin
 * @Author:技术铺<jishupu@qq.com>
 * @Date: 2021/11/11
 */

namespace App\Models;

use App\Traits\BaseModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

/**
 * 信息模型表模型
 *
 * Class InfoModel
 * @package App\Models
 */
class InfoModel extends Model
{
    use BaseModel, HasFactory;

    /**
     * 指定表名
     */
    protected $table = 'info_model';

    /**
     * The attributes that are mass assignable.
     *
     * @var string[]
     */
    protected $fillable = [];

    /**
     * 不能被批量赋值的属性
     *
     * @var array
     */
    protected $guarded = [];

    /**
     * The attributes that should be hidden for serialization.
     * 数据显示时，设置了敏感信息字段数据中不显示
     * @var array
     */
    protected $hidden = [
        'deleted_at',
        'created_at',
        'updated_at',
        'created_user_id',
    ];

    /**
     * The attributes that should be cast.
     * 显示数据时类型转换
     *
     * @var array
     */
    protected $casts = [
    ];

    /**
     * 关联管理员信息
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function user()
    {
        return $this->hasOne(User::class, 'id', 'created_user_id');
    }
}
